package adaptation;

import dao.Apple;
import dao.Fruits;
import dao.Mango;
import dao.Strawberry;
import server.FruitsService;
import server.FruitsServiceImpl;


public class FruitsAdaptation {
    private static FruitsService fruitsService = new FruitsServiceImpl();

    public Double calculation(Fruits fruits) {
        if (fruits.getType().equals("苹果")) {
            return ((Apple) fruits).calculationApple(fruitsService, fruits);
        }
        if (fruits.getType().equals("草莓")) {
            return ((Strawberry) fruits).calculationStrawberry(fruitsService, fruits);
        }
        if (fruits.getType().equals("芒果")) {
            return ((Mango) fruits).calculationMango(fruitsService, fruits);
        }
        return 0.0;
    }


    public Double calculationReduction(Double price, Double limit, Double free) {
        return fruitsService.FullReductionFruits(price, limit, free);
    }


}
